﻿using System;
using Microsoft.Practices.EnterpriseLibrary.PolicyInjection.CallHandlers;
using Microsoft.Practices.Unity;
using Microsoft.Practices.EnterpriseLibrary.Validation.PolicyInjection;

namespace TSharp.Core.Test
{

    public interface ISyncTimeServiceProvision
    {
        [ValidationCallHandler(Order = 0, SpecificationSource = SpecificationSource.Both)]
        [HandlerB(Order = 2)]
        [HandlerA(Order = 1)]
        //[CachingCallHandler]
        DateTime GetCurrentTime();

        String GetBorthDay();
    }
    public class SyncTimeServiceProvisionService : ISyncTimeServiceProvision
    {
        public ISyncTimeProvider SyncTimeProvider
        { get; private set; }
        public SyncTimeServiceProvisionService()
        {
        }
        public SyncTimeServiceProvisionService(
            [Dependency]
            ISyncTimeProvider syncTimeServiceProvider)
        {
            this.SyncTimeProvider = syncTimeServiceProvider;
        }
        #region ISyncTimeServiceProvision Members
        public DateTime GetCurrentTime()
        {
            return this.SyncTimeProvider.GetCurrentTime();
        }
        #endregion

        #region ISyncTimeServiceProvision 成员


        public String GetBorthDay()
        {
            return "19820304";
        }

        #endregion
    }
    [HandlerA(Order = 1)]
    public interface ISyncTimeProvider
    {
        [HandlerB(Order = 2)]
        DateTime GetCurrentTime();

        string GetName();

        int Age { get; }
    }


    public class SyncTimeProvider : ISyncTimeProvider
    {
        #region ISyncTimeServiceProvider Members

        public DateTime GetCurrentTime()
        {
            return DateTime.Now;
        }
        #endregion

        #region ISyncTimeProvider 成员


        public string GetName()
        {
            return ">>My Name ";
        }

        #endregion

        #region ISyncTimeProvider 成员


        public int Age
        {
            get { return 18; }
        }

        #endregion
    }
}
